home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16598 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: newshost.centrum.is!news
  2. From: bjarnir@centrum.is (Bjarni Ragnarsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Array declaration
  5. Date: 11 Apr 1996 15:08:55 GMT
  6. Organization: BR Software
  7. Message-ID: <4kj7a7$m72@newshost.centrum.is>
  8. References: <4jvo2g$mp2@hermes.is.co.za>
  9. NNTP-Posting-Host: tungl-54.centrum.is
  10. X-Newsreader: WinVN version 0.82
  11.  
  12. In article <4jvo2g$mp2@hermes.is.co.za>, janinep@geoscience.org.za (Janine Prinsloo) says:
  13. >
  14. >I declared the following array:  dat[7][2048]
  15. >In the program I made the stupid mistake of using loops going from 1 to 7
  16. >and from 1 to 2048 instead of 0 to 6 and 0 to 2047. What I don't understand
  17. >is that the program ran fine for a number of times (the program is repeatedly
  18. >run by a batch program) before an error occurred.
  19. >
  20. >I would like to know why an error didn't occur immediately the first time
  21. >the program was run. 
  22. >
  23. >Janine
  24. >
  25. >(I used Borland C++ v4.0 to compile the program)
  26.  
  27. What sort of error did it give....Out of range or something like that ?
  28.  
  29. I don't believe any range checking is done.  Your range (7x2048) instructs the 
  30. compiler to reserve memory of that size for your array.  
  31. If you go outside the predefined range, that is your problem.  If you write outside 
  32. the predefined range, you are however (probably) poking into "someone" else's 
  33. address with unpredictible results.  Sometimes it doesn't matter and sometimes 
  34. it does.
  35.  
  36. Bjarni Ragnarsson
  37. bjarnir@centrum.is
  38.